package com.ibuonline.b2b.entity;

import java.io.Serializable;

import com.dimeng.common.util.StringUtil;
import com.ibuonline.b2b.common.Constants;
import com.ibuonline.b2b.common.ResourceUtil;

public class ShopAlbum implements Serializable {

	private static final long serialVersionUID = -1041513455815733948L;

	//fields
	private java.lang.Integer id;
	private java.lang.String name;
	private java.lang.Integer companyId;
	private java.lang.String cover;
	private java.lang.String descr;
	private java.sql.Timestamp createTime;
	private java.lang.Boolean display;
	private java.lang.Integer displayOrder;
	private java.sql.Timestamp lastupdate;

	//default constructor
	public ShopAlbum() {
	}

	//getter
	public java.lang.Integer getId() {
		return id;
	}
	public java.lang.String getName() {
		return name;
	}
	public java.lang.Integer getCompanyId() {
		return companyId;
	}
	public java.lang.String getCover() {
		return cover;
	}
	public java.lang.String getDescr() {
		return descr;
	}
	public java.sql.Timestamp getCreateTime() {
		return createTime;
	}
	public java.lang.Boolean isDisplay() {
		return display;
	}
	public java.lang.Integer getDisplayOrder() {
		return displayOrder;
	}
	public java.sql.Timestamp getLastupdate() {
		return lastupdate;
	}

	//setter
	public void setId(java.lang.Integer id) {
		this.id = id;
	}
	public void setName(java.lang.String name) {
		this.name = name;
	}
	public void setCompanyId(java.lang.Integer companyId) {
		this.companyId = companyId;
	}
	public void setCover(java.lang.String cover) {
		this.cover = cover;
	}
	public void setDescr(java.lang.String descr) {
		this.descr = descr;
	}
	public void setCreateTime(java.sql.Timestamp createTime) {
		this.createTime = createTime;
	}
	public void setDisplay(java.lang.Boolean display) {
		this.display = display;
	}
	public void setDisplayOrder(java.lang.Integer displayOrder) {
		this.displayOrder = displayOrder;
	}
	public void setLastupdate(java.sql.Timestamp lastupdate) {
		this.lastupdate = lastupdate;
	}

	//equals method
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof ShopAlbum))
			return false;

		final ShopAlbum shopAlbum = (ShopAlbum)other;
		if (!this.id.equals(shopAlbum.getId()))
			return false;

		return true;
	}

	//hashCode method
	public int hashCode() {
		StringBuffer keys = new StringBuffer();
		keys.append(id).append(",");
		if (keys.length() > 0)
			keys.deleteCharAt(keys.length() - 1);
		return keys.toString().hashCode();
	}

	//toString method
	public String toString() {
		return new StringBuilder("ShopAlbum[")
			.append("id=").append(id).append(", ")
			.append("name=").append(name).append(", ")
			.append("companyId=").append(companyId).append(", ")
			.append("cover=").append(cover).append(", ")
			.append("descr=").append(descr).append(", ")
			.append("createTime=").append(createTime).append(", ")
			.append("display=").append(display).append(", ")
			.append("displayOrder=").append(displayOrder).append(", ")
			.append("lastupdate=").append(lastupdate).append("]").toString();
	}
	
	///#############
	private int photoNums;
	
	private int uploadFailures;
	private int photosUploaded;
	
	public String getShowName() {
		if(name != null) {
			if(name.length() > 5) {
				return StringUtil.truncate(name, 5)+"...";
			} else {
				return name;
			}
		}
		return "";
	}
	
	public int getPhotoNums() {
		return photoNums;
	}

	public void setPhotoNums(int photoNums) {
		this.photoNums = photoNums;
	}

	public java.lang.Boolean getDisplay() {
		return display;
	}
	
	public String getCoverResPath() {
		if(Constants.SHOP_ALBUM_DEFAULT_COVER.equals(cover)) {
			return cover;
		}
		return ResourceUtil.getResPath(cover, Constants.PIC_SIZE_MIDDLE);
	}

	public int getUploadFailures() {
		return uploadFailures;
	}

	public void setUploadFailures(int uploadFailures) {
		this.uploadFailures = uploadFailures;
	}

	public int getPhotosUploaded() {
		return photosUploaded;
	}

	public void setPhotosUploaded(int photosUploaded) {
		this.photosUploaded = photosUploaded;
	}
}